<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Functions</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Copyright   : 2010 Bryan O'Sullivan</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- /Warning/: this is an internal module, and does not have a stable</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- API or name. Functions in this module may not check or enforce</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- preconditions expected by public modules. Use at your own risk!</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Useful functions.</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Functions</span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Functions.html#intersperse"><span class="hs-identifier">intersperse</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Ptr.html#"><span class="hs-identifier">Foreign.Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.ForeignPtr.html#"><span class="hs-identifier">Foreign.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if MIN_VERSION_base(4,15,0)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="hs-identifier">Foreign.ForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">withForeignPtr</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- | A lazier version of Data.List.intersperse.  The other version</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- causes space leaks!</span><span>
</span><span id="line-34"></span><span id="local-6989586621679104304"><span class="annot"><a href="Data.Text.Internal.Functions.html#intersperse"><span class="hs-identifier hs-type">intersperse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679104304"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679104304"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679104304"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-35"></span><span id="intersperse"><span class="annot"><span class="annottext">intersperse :: forall a. a -&gt; [a] -&gt; [a]
</span><a href="Data.Text.Internal.Functions.html#intersperse"><span class="hs-identifier hs-var hs-var">intersperse</span></a></span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-36"></span><span class="annot"><a href="Data.Text.Internal.Functions.html#intersperse"><span class="hs-identifier hs-var">intersperse</span></a></span><span> </span><span id="local-6989586621679104293"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104293"><span class="hs-identifier hs-var">sep</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679104292"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104292"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679104291"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679104291"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104292"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
</span><a href="#local-6989586621679104290"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679104291"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-37"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-38"></span><span>    </span><span id="local-6989586621679104290"><span class="annot"><span class="annottext">go :: [a] -&gt; [a]
</span><a href="#local-6989586621679104290"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><a href="#local-6989586621679104290"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679104289"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104289"><span class="hs-identifier hs-var">y</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679104288"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679104288"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104293"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104289"><span class="hs-identifier hs-var">y</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
</span><a href="#local-6989586621679104290"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679104288"><span class="hs-identifier hs-var">ys</span></a></span><span>
</span><span id="line-40"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Functions.html#intersperse"><span class="hs-pragma hs-type">intersperse</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span id="local-6989586621679104299"><span id="local-6989586621679104301"><span class="annot"><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-type">unsafeWithForeignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104301"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104301"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104299"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104299"><span class="hs-identifier hs-type">b</span></a></span></span></span><span class="hs-cpp">
#if MIN_VERSION_base(4,15,0)
</span><span id="unsafeWithForeignPtr"><span class="annot"><span class="annottext">unsafeWithForeignPtr :: forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var hs-var">unsafeWithForeignPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">GHC.ForeignPtr.unsafeWithForeignPtr</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">unsafeWithForeignPtr</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Foreign.ForeignPtr.withForeignPtr</span><span class="hs-cpp">
#endif
</span></pre></body></html>